import request from '@/apis/request';
/**
 * login 登录接口
 * @param data
 * @returns
 */

//代客祭扫保存
export const saveReplaceVisitAGraveApi = (data?: Object) => {
    return request(
        {
            url: '/cemetery/fxyweixin/saveReplaceVisitAGrave',
            method: 'post',
            data,
        },
        true,
        true
    );
};
export const fileUploadBase64ExApi = (data?: Object) => {
    return request(
        {
            url: '/business/api/file/fileUploadBase64Ex',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 身份证验证接口
export const idOrcApi = (data?: Object) => {
    return request(
        {
            url: '/api/api/baiduApi/idCard',
            method: 'post',
            data,
        },
        true,
        true
    );
};
//墓区
export const getAareaApi = (data?: Object) => {
    return request(
        {
            url: '/cemetery/WeiXin/getAarea',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 墓穴编号
export const getCemeteryApi = (data?: Object) => {
    return request(
        {
            url: '/cemetery/hlfxy/getCemetery',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 带客祭扫查询服务列表
export const getPackageListApi = (data?: Object) => {
    return request(
        {
            url: '/cemetery/fxyweixin/getPackageList',
            method: 'post',
            data,
        },
        true,
        true
    );
};
//保存墓位报修
export const saveCemeteryRepairApi = (data?: Object) => {
    return request(
        {
            url: '/cemetery/WeiXin/saveCemeteryRepair',
            method: 'post',
            data,
        },
        true,
        true
    );
};

// 遗体接运预约查看
export const getRecordDetailsApi = (data?: Object) => {
    return request(
        {
            url: '/bygex/kmxWeiXin/getRecordDetails',
            method: 'post',
            data,
        },
        true,
        true
    );
};

// 预约记录取消预约
export const getCancellationRecordApi = (data?: Object) => {
    return request(
        {
            url: '/bygex/kmxWeiXin/getCancellationRecord',
            method: 'post',
            data,
        },
        true,
        true
    );
};

// 墓位查询列表
export const WSJSYTJApi = (data?: Object) => {
    return request(
        {
            url: '/cemetery/fhs/print/WSJSYTJ',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 墓位查询信息
export const WXZFXFApi = (data?: Object) => {
    return request(
        {
            url: '/cemetery/fhs/print/WXZFXF',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 续费记录
export const FHSXFJLApi = (data: Object) => {
    return request(
        {
            url: '/cemetery/fhs/print/FHSXFJL',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 微信支付--暂时不对
// 1.获取access_token
export const weixinCgiBinAccessTokenApi = (params: Object) => {
    return request(
        {
            url: '/cgi-bin/token',
            method: 'get',
            params,
        },
        true,
        true
    );
};
// 2.用第一步拿到的access_token 采用http GET方式请求获得jsapi_ticket（有效期7200秒，开发者必须在自己的服务全局缓存jsapi_ticket）
export const weixinGetticketApi = (params: Object) => {
    return request(
        {
            url: '/cgi-bin/ticket/getticket',
            method: 'get',
            params,
        },
        true,
        true
    );
};

// JSApi下单
export const jsapiApi = (data: Object, Authorization) => {
    return request(
        {
            url: '/v3/pay/transactions/jsapi',
            method: 'post',
            headers: {
                Authorization,
                Accept: 'application/json',
                'Content-Type': 'application/json',
            },
            data,
        },
        true,
        true
    );
};
export const wechatPayApi = (data: Object) => {
    return request(
        {
            url: '/cemetery/fhs/print/wechatPay',
            method: 'post',
            data,
        },
        true,
        true
    );
};

// 微信
// 第二步：通过code换取网页授权access_token
// appid：公众号的唯一标识 secret：公众号的appsecret code：填写第一步获取的code参数 grant_type：填写为authorization_code
export const weixinAccessTokenApi = (params: Object) => {
    return request(
        {
            // url: "https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code",
            url: '/sns/oauth2/access_token',
            // url: '/sns/oauth2/access_token?appid=' + params.appid + '&secret=' + params.secret + '&code=' + params.code + '&grant_type=authorization_code',
            method: 'get',
            params,
        },
        true,
        true
    );
};
// 第三步：刷新access_token（如果需要）
// appid：公众号的唯一标识 grant_type：填写为refresh_token refresh_token：填写通过access_token获取到的refresh_token参数
export const weixinRefreshTokenApi = (params: Object) => {
    return request(
        {
            url: '/sns/oauth2/refresh_token',
            method: 'get',
            params,
        },
        true,
        true
    );
};
// 第四步：拉取用户信息(需scope为 snsapi_userinfo)
// appid：公众号的唯一标识 grant_type：填写为refresh_token refresh_token：填写通过access_token获取到的refresh_token参数
export const weixinUserinfoApi = (params: Object) => {
    return request(
        {
            url: '/sns/userinfo',
            method: 'get',
            params,
        },
        true,
        true
    );
};

// export const HTSJDApi = (data?: Object) => {
//     return request({
//         url: '/cemetery/lygrwy/print/HTSJD',
//         method: 'post',
//         data
//     },true,true);
// }

//注册
export const saveUserApi = (data?: object) => {
    return request(
        {
            url: '/api/api/loginWeixin/saveUser',
            method: 'post',
            data,
        },
        true,
        true
    );
};
// 登录
export const checkLoginApi = (data?: object) => {
    return request(
        {
            url: '/api/api/loginWeixin/checkLogin',
            method: 'post',
            data,
        },
        true,
        true
    );
};
